<template>
  <div class="Login">
    <img
      src="https://api.java.crmeb.net/crmebimage/public/operation/2021/09/23/e50ee2515544455a826990701abdaf90jhr0s3jzfp.png"
      class="avatar"
    />
    <!-- 可以使用 CellGroup 作为容器 -->
    <van-cell-group inset>
      <van-field v-model="value" left-icon="phone" placeholder="请输入电话" />

      <van-field
        v-model="password"
        type="password"
        left-icon="lock"
        placeholder="密码"
      />
    </van-cell-group>
    <div class="button" @click="Login">登录</div>
  </div>
</template>

<script>
export default {
  name: "FxhDemoLogin",

  data() {
    return {
      value: undefined,
      password: undefined,
      LoginData: null,
      token: undefined,
    };
  },

  mounted() {},

  methods: {
    async Login() {
      const {
        data: { data },
      } = await this.LoginRequest("/fxh/login", {
        account: this.value, //账户，手机号
        password: this.password, //密码
      });
      this.LoginData = data;
      this.token = this.LoginData.token;
      localStorage.setItem("token", this.token);
      if (this.token) {
        const destPath = this.$route.query.redirect;
        if (destPath) this.$router.replace(destPath);
        else this.$router.replace("/");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.Login {
  width: 375px;
  height: 100vh;
  background: #f5f5f5;
  .avatar {
    width: 89px;
    height: 89px;
    border-radius: 50%;
    margin-left: 140px;
    margin-top: 25vh;
  }
  .van-cell-group {
    margin-top: 35px;
  }
  .button {
    width: 347px;
    height: 42px;
    background: #ff448f;
    border-radius: 25px;
    text-align: center;
    line-height: 42px;
    color: white;
    margin-left: 15px;
    margin-top: 7vh;
  }
}
</style>
